home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / CLOCK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  621 b   |  25 lines

  1. /* clock.c              Turbo C Bible functions, p. 329 */
  2. #include <stdio.h>
  3. #include <time.h>
  4. main()
  5. {
  6.     unsigned i, tused, count=10000;
  7.     double a, b, c, d;
  8.     clock_t ticksnow;
  9.     for(i = 0; i < count; i++)
  10.     {
  11.         a = (double)(i-1);
  12.         b = (double)(i+1);
  13.         c = (double)(i*i);
  14.         d = a*b - c;
  15.     }
  16.     if ((ticksnow = clock()) == (clock_t)-1)
  17.             /* Get current clock ticks by calling "clock" */
  18.     {
  19.         printf("Processor time not available!\n");
  20.         abort();
  21.     }
  22.     tused = (unsigned) ticksnow / CLK_TCK;
  23.             /* Convert processor time to seconds.  Use CLK_TCK */
  24.     printf("10,000 loops ran for %u seconds\n", tused);
  25. }